/*
 * @Author: your name
 * @Date: 2021-08-06 09:26:43
 * @LastEditTime: 2021-11-05 14:40:56
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \jinfeng_up\src\utils\request.js
 */
import axios from 'axios'

const _axiosConfig = {
    baseURL: process.env.VUE_APP_BASE_API,
    timeout: 60 * 1000
}
const axiositem = axios.create(_axiosConfig)
axiositem.interceptors.request.use(
    options => {
    // Do something before request is sent
    // options.headers['Cache-Control'] = 'no-cache';
        if (options.url != '/login') {
            // options.headers['token'] = localStorage.getItem('token')
            options.headers['token'] = JSON.parse(sessionStorage.getItem('USERINFO')).token
        }
        return options
    },
    error => {
    // Do something with request error
        return Promise.reject(error)
    }
)

axiositem.interceptors.response.use(
    response => {
    // Do something with response data
        return response.data
    },
    error => {
        console.log(error)
        return Promise.reject()
    }
)

export default axiositem
